package com.shop.controller;

import com.github.pagehelper.PageInfo;
import com.shop.base.BaseController;
import com.shop.entity.Banner;
import com.shop.result.ResultVO;
import com.shop.service.BannerService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author XCH
 * @date 2025 - 06 - 18
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/banner")
public class BannerController extends BaseController {
    private final BannerService bannerService;
    @RequestMapping("/listBanner")
    public ResultVO<PageInfo<Banner>> listBanner(@RequestParam("pageNo") Integer pageNum, @RequestParam("pageSize") Integer pageSize){
        PageInfo<Banner> list = bannerService.listBanner(pageNum, pageSize);
        return success(list);
    }
    @GetMapping("/addBanner")
    public ResultVO<Object> addBanner(Banner banner){
        bannerService.addBanner(banner);
        return success();
    }
    @GetMapping("/deleteBanner")
    public ResultVO<Object> deleteBanner(@RequestParam("id") Integer id){
        bannerService.deleteBanner(id);
        return success();
    }
    @GetMapping("/updateBanner")
    public ResultVO<Object> updateBanner(Banner banner){
        bannerService.updateBanner(banner);
        return success();
    }
}
